/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef I_INFER_CLIENT_INL
#define I_INFER_CLIENT_INL

#include <vector>

#include "client_factory.h"
#include "i_client_cb.h"
#include "protocol/retcode_inner/infer_retcode_inner.h"
#include "protocol/struct_definition/infer_info_define.h"
#include "utils/infer_macros.h"
#include "utils/log/infer_log.h"

namespace OHOS {
namespace AI_STD {
inline int ClientInit(const ConfigInfo &configInfo, ClientInfo &clientInfo,
    const AlgorithmInfo &algorithmInfo, IServiceDeadCb *cb)
{
    HILOGI("[IAieClient]ClientInit");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientInit(configInfo, clientInfo, algorithmInfo, cb);
}

inline int ClientPrepare(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo,
    const DataInfo &inputInfo, DataInfo &outputInfo, IClientCb *cb)
{
    HILOGI("[IAieClient]ClientPrepare");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientPrepare(clientInfo, algorithmInfo, inputInfo, outputInfo, cb);
}

inline int ClientAsyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo,
    const DataInfo &inputInfo)
{
    HILOGI("[IAieClient]ClientAsyncProcess");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientAsyncProcess(clientInfo, algorithmInfo, inputInfo);
}

inline int ClientDestroy(ClientInfo &clientInfo)
{
    HILOGI("[IAieClient]ClientDestroy");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientDestroy(clientInfo);
}

inline int ClientSetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo)
{
    HILOGI("[IAieClient]ClientSetOption");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientSetOption(clientInfo, optionType, inputInfo);
}

inline int ClientGetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo,
    DataInfo &outputInfo)
{
    HILOGI("[IAieClient]ClientGetOption");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientGetOption(clientInfo, optionType, inputInfo, outputInfo);
}

inline int ClientRelease(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo,
    const DataInfo &inputInfo)
{
    HILOGI("[IAieClient]ClientRelease");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientRelease(clientInfo, algorithmInfo, inputInfo);
}

inline int ClientSyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo,
    const DataInfo &inputInfo, DataInfo &outputInfo)
{
    HILOGI("[IAieClient]ClientSyncProcess.");
    ClientFactory *client = ClientFactory::GetInstance();
    CHK_RET(client == nullptr, RETCODE_NULL_PARAM);
    return client->ClientSyncProcess(clientInfo, algorithmInfo, inputInfo, outputInfo);
}
} // namespace AI_STD
} // namespace OHOS

#endif // I_INFER_CLIENT_INL
